'use strict';

import React from 'react';
import {
    StyleSheet,
    Image,
    Animated,
    View,
    Text,
    Alert,
    StatusBar,
    Platform,
} from 'react-native';
import Global from '../Commom/GlobalConst';
import Main from './Main';
import SplashScreen from 'react-native-splash-screen';

class Splash extends React.Component {
    constructor(props) {
        super(props);
    }

    componentDidMount() {
        const {
            navigator
        } = this.props;
        SplashScreen.hide();
        setTimeout(()=> {
            navigator.resetTo({
                component: Main,
                name: 'Main',
            });
        }, 2000);
    }

    randomNum(Min, Max) {
        var Range = Max - Min;
        var Rand = Math.random();
        return (Min + Math.round(Rand * Range));
    }

    render() {
        var THUMB_URLS = Global.AdImg;
        var i = this.randomNum(0, THUMB_URLS.length - 1);
        var imgSource = THUMB_URLS[i];
        return (
            <View style={{flex:1,backgroundColor:'white',alignItems:'center'}}>
                <Image source={require('../../Image/splash_logo.png')} style={styles.coverimage}/>
                <Image style={{marginTop:10,width:180,height:70,resizeMode:'contain'}}
                       source={require('../../Image/splash_logo_text.png')}></Image>
            </View>
        );
    }
}
const styles = StyleSheet.create({
    animateimage: {
        backgroundColor: 'white',
    },
    coverimage: {
        width: Global.Const.size.width,
        height: Global.Const.size.height - 90,
    },
});
export default Splash;